package com.situ.studentmanagement.controller.api;

import com.situ.studentmanagement.dao.GoodsMapper;
import com.situ.studentmanagement.dao.ManageMapper;
import com.situ.studentmanagement.dao.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by Administrator on 2016/8/3.
 */
@RestController
@RequestMapping("/api/main")
public class UserController {

    @Autowired
    UserMapper userMapper;
    @Autowired
    ManageMapper manageMapper;
    @Autowired
    GoodsMapper goodsMapper;

    //管理页面删除用户
    @RequestMapping("/deluser")
    public Map deletuse(Model model,
                          @RequestParam("id")int id) {
        userMapper.deleteUserById(id);
        Map map=new HashMap();
        map.put("deleId",id);
        return map;
    }

    //删除员工
    @RequestMapping("/delmanager")
    public Map delmanager(Model model,
                          @RequestParam("id")int id){
        manageMapper.deletManagerById(id);
        Map map=new HashMap();
        map.put("deleId",id);

        return map;
    }

    //管理页面删除菜品
    @RequestMapping("/delgoods")
    public Map delgoods(Model model,
                        @RequestParam("id")int id) {
        goodsMapper.deleteGoodById(id);
        Map map=new HashMap();
        map.put("deleId",id);
        return map;
    }


}
